#include <iostream>
#include <string>
#include <unistd.h>
#include "../Worker.h"
#include "../BlockQueue.h"

using namespace BASE;
class TestWorker;

class TestTask: public ITask{
public:
	TestTask(TestWorker * _worker):worker(_worker) {}

	virtual void run();

	ITask * clone(){
		return new TestTask(worker);
	}

private:
	TestWorker * worker;
};

class TestTaskA: public ITask{
	public:
		TestTaskA(TestWorker * _worker): worker(_worker){

		}

		virtual void run();

		ITask * clone(){
			return new TestTaskA(worker);
		}

	private:
		TestWorker * worker;
};

class TestWorker: public Worker{
	friend TestTask;
	friend TestTaskA;
	public:
		TestWorker(const std::string & name):Worker(name),blockQueue(new BlockQueue<std::string>(name)){
			task = new TestTask(this);
			taskA = new TestTaskA(this);
			create(task);
			create(taskA);
		}
		~TestWorker(){
			blockQueue->stop();
		}
	private:
		BlockQueue<std::string> *blockQueue;
		TestTask * task;
		TestTaskA * taskA;
};

